<?php

// Set include path to parent director (root of application)
define('SITE_PATH', dirname(dirname(realpath(__FILE__))));
set_include_path(SITE_PATH);

function __autoload($class_name)
{
	// This does not use ConfigLoader because it has not yet been loaded into
	// memory (i.e. included/required).
	$j = json_decode(file_get_contents('config/classes.config.json'), true);
	if (array_key_exists($class_name, $j))
	{
		require_once($j[$class_name].'/'.$class_name.'.php');
	}
}

// Hand off the work to the controller
$c = new Application();
$c->begin_request();
$c->write_response(); // Write both headers and content

?>